package com.liuxu.topnews.function;

import android.util.Log;

import com.liuxu.topnews.Manager.ActionManager;
import com.liuxu.topnews.MyApplication;
import com.liuxu.topnews.bean.App;
import com.liuxu.topnews.utils.ShareUtil;
import com.liuxu.topnews.utils.ToastUtils;

import static com.liuxu.topnews.MyApplication.NowClassName;
import static com.liuxu.topnews.MyApplication.cycle_time;
import static com.liuxu.topnews.MyApplication.globalapp;
import static com.liuxu.topnews.MyApplication.video_read;


public class Read {
    private final int wrongtimes=4;
    private int time;
    private int wrong;
    private long begintime;
    public ActionManager actionManager;

    public void funnews() throws InterruptedException {
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.Click(600,100);
        Thread.sleep(800);
        actionManager.Back();
        actionManager.ClickText("任务");
        Thread.sleep(3000);
        actionManager.ClickText("头条");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            Thread.sleep(1000);
            actionManager.ClickText("评");
            Thread.sleep(3000);
            Log.v("now==" + NowClassName, "窗口变动");
            if (checkactivity()){
                actionManager.ClickText("继续观看");
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void eastnews( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("继续赚钱");
        actionManager.ClickText("领取");
        actionManager.Back();
        actionManager.ClickText("继续赚钱");
        actionManager.Home_Up(2,200);
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.ClickText("继续赚钱");
            actionManager.Home_Up(2,200);
            Thread.sleep(1000);
            if (!actionManager.ClickText("阅读")){
                if (!actionManager.ClickText("分钟前")){
                    actionManager.ClickText("次播放");
                }
            }
            Thread.sleep(3000);
            if (checkactivity()){
                actionManager.ClickText("继续播放");
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void newsmoremore( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("赚钱");
        Thread.sleep(2000);
        actionManager.ClickText("首页");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.Click(350,650);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Click(100,1250);
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void youthnews( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.Click(630,1240);
        actionManager.Click(380,350);
        actionManager.Back();
        actionManager.Back();
        actionManager.ClickText("首页");
        actionManager.ClickText("刷新");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(3000);
            actionManager.Home_Up(3,200);
            actionManager.ClickText("阅读");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void weliseesee( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            Thread.sleep(1000);
            actionManager.ClickId("cn.weli.story:id/ll_pictures");
            Thread.sleep(2000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(2,200);
                actionManager.ClickText("展开查看全文");
                actionManager.ReadNews();
                if(time==10){
                    actionManager.Click(50,100);
                    Thread.sleep(2000);
                    actionManager.Click(300,200);
                    actionManager.Back();
                    actionManager.Back();
                }
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void sohunews( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("任务");
        actionManager.Click(600,420);
        actionManager.Back();
        actionManager.ClickText("首页");
        actionManager.ClickText("刷新");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            if (!actionManager.ClickText("刚刚")){
                if (!actionManager.ClickText("分钟前")){
                    actionManager.ClickText("次播放");
                }
            }
            Thread.sleep(3000);
            if (checkactivity()){
                actionManager.ClickText("继续播放");
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void bullnews( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("领取");
        Thread.sleep(2000);
        actionManager.Back();
        actionManager.ClickText("每日金币");
        Thread.sleep(1000);
        actionManager.ClickText("资讯");
        actionManager.ClickText("刷新");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.Click(350,650);
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
                Thread.sleep(2000);
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void haicao( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        Thread.sleep(2000);
        actionManager.Back();
        actionManager.ClickText("草原");
        Thread.sleep(800);
        actionManager.ClickText("领取");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.ClickId("com.billionstech.grassbook:id/tv_find_list_summary_type_1");
            actionManager.ClickId("com.billionstech.grassbook:id/tv_find_list_summary_type_2");
            Thread.sleep(4000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                Log.v("判断页面","失败");
                wrong-=1;
                actionManager.Back();
            }
        }
        actionManager.Back();
        actionManager.Close(globalapp.packname);
    }
    public void shandianhezi( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        Thread.sleep(2000);
        actionManager.ClickText("首页");
        Thread.sleep(2000);
        actionManager.Back();
        actionManager.ClickText("逛逛领币");
        while(time>1){
            Thread.sleep(1000);
            actionManager.OpenAPP();
            actionManager.Home_Up(1,200);
            actionManager.Click(350,650);
            Thread.sleep(1500);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(1,200);
                actionManager.Click(650,950);
                Thread.sleep(1000);
                actionManager.Click(400,1020);
                actionManager.Click(400,930);
                actionManager.ClickId("c.l.a:id/like_iv");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                if (wrong==0){
                    wrong=wrongtimes;
                    actionManager.Close(globalapp.packname);
                }
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.ClickText("首页");
        Thread.sleep(2000);
        actionManager.Back();
        time= globalapp.pagenumber;
        while(time>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.ClickId("c.l.a:id/image3");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Click(650,950);
                Thread.sleep(1000);
                actionManager.Click(400,1020);
                actionManager.Click(400,930);
                actionManager.ReadNews();
                actionManager.Home_Down(6,200);
                time-=1;
            }else {
                wrong-=1;
                if (wrong==0){
                    wrong=wrongtimes;
                    actionManager.Close(globalapp.packname);
                }
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Back();
        actionManager.Close(globalapp.packname);
    }

    public void mayinews( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.Click(100,200);
        Thread.sleep(1000);
        actionManager.Back();
        actionManager.Click(500,1250);
        Thread.sleep(2000);
        actionManager.Click(400,400);
        Thread.sleep(2000);
        actionManager.Back();
        actionManager.Click(50,1250);
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.ClickId("com.ldzs.zhangxin:id/tv_read_count");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Down(3,200);
                Thread.sleep(2000);
                actionManager.ClickDesc("open");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void hbnews( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.Click(350,1200);
        actionManager.Back();
        actionManager.Click(600,300);
        actionManager.Back();
        actionManager.Click(80,1250);
        actionManager.Home_Up(2,200);
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(1000);
            actionManager.Home_Up(3,200);
            actionManager.Click(350,650);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void kankanzhuan( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("领取");
        Thread.sleep(1000);
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            Thread.sleep(1000);
            actionManager.ClickText("阅读");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(2,140);
                actionManager.ClickText("查看全文");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void qukantianxia( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("领取");
        Thread.sleep(2000);
        actionManager.Back();
        actionManager.ClickText("每日金币");
        Thread.sleep(4000);
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.Click(350,650);
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(2,200);
                Thread.sleep(1000);
                actionManager.ClickDesc("展开查看全文");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void newsbus( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.Click(100,90);
        actionManager.Back();
        actionManager.Click(100,1250);
        Thread.sleep(1000);
        actionManager.Click(100,1250);
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Click(100,1250);
            Thread.sleep(1000);
            actionManager.Click(350,650);
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void huashengnews( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.Click(50,1250);
        while(time>1&&wrong>1){
            actionManager.Home_Up(2,200);
            Thread.sleep(1000);
            actionManager.Click(350,650);
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
        }
        actionManager.Click(650,100);//右上角签到
        actionManager.Close(globalapp.packname);
    }
    public void mangguokandian( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("领取");
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.Home_Up(2,200);
            Thread.sleep(1000);
            actionManager.ClickText("阅读");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void songshu( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("赚钱");
        Thread.sleep(2000);
        actionManager.Click(328,271);
        Thread.sleep(1000);
        actionManager.ClickText("首页");
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            Thread.sleep(1000);
            actionManager.ClickText("看过");
            Thread.sleep(3000);
            Log.v("等待","等待窗口刷新");
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(1,200);
                Thread.sleep(1000);
                actionManager.ClickText("查看全文");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void huitoutiao( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("点击领取");//时段奖励
        actionManager.Back();
        actionManager.ClickText("任务中心");
        Thread.sleep(1000);
        actionManager.ClickId("com.cashtoutiao:id/sign_btn_container");
        actionManager.Back();
        Thread.sleep(1000);
        actionManager.Click(92,1241);
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.ClickId("com.cashtoutiao:id/tv_read_count");
            Thread.sleep(3000);
            if (checkactivity()){
                actionManager.ClickText("播放视频");
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void zhangshangnews( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("任务");
        Thread.sleep(3000);
        actionManager.Back();
        actionManager.ClickText("首页");
        Thread.sleep(2000);
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.Click(350,650);
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(2,200);
                Thread.sleep(1000);
                actionManager.ClickText("查看全文");
                actionManager.Home_Down(2,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void zhongzishiping( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("领取");
        actionManager.Back();
        actionManager.ClickText("赚钱");
        Thread.sleep(1000);
        actionManager.ClickText("签到领金币");
        actionManager.Click(100,1250);
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.Click(350,650);
            Thread.sleep(3000);
            if (checkactivity()){
                actionManager.ClickText("继续播放");
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void qukandian( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Click(100,1250);
        actionManager.Back();
        actionManager.Home_Up(1,200);
        actionManager.Click(100,100);
        actionManager.Back();
        actionManager.Click(500,1200);
        Thread.sleep(1000);
        actionManager.Click(550,260);
        actionManager.Back();
        actionManager.Click(100,1250);
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.Home_Up(2,200);
            actionManager.ClickText("阅读");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(2,200);
                actionManager.ClickId("com.zhangku.qukandian:id/header_information_read_all_btn");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void yuequ( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("任务中心");
        Thread.sleep(2000);
        actionManager.Click(350,300);
        Thread.sleep(1000);
        actionManager.Back();
        actionManager.Click(100,1250);
        while(time>1&&wrong>1){
            actionManager.Home_Up(2,200);
            actionManager.Click(350,650);
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(3,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void jukandian( ) throws Exception {
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.ClickText("一键签到");
        Thread.sleep(1000);
        actionManager.Back();
        actionManager.ClickId("com.xiangzi.jukandian:id/icon_home_left_timer_lq");
        Thread.sleep(1000);
        actionManager.ClickText("任务中心");
        Thread.sleep(3000);
        actionManager.ClickText("签到领金币");
        actionManager.Click(100,1250);
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(4000);
            actionManager.Home_Up(2,200);
            Thread.sleep(2000);
            actionManager.ClickText("阅读");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(2,200);
                Thread.sleep(2000);
                actionManager.ClickDesc("see");
//                actionManager.ClickNodes(accesser.findNodesByText("评论得金币"));
//                actionManager.ClickNodes(accesser.findNodesById("com.xiangzi.jukandian:id/dialog_comment_content"));
//                accesser.set_text(accesser.findNodesById("com.xiangzi.jukandian:id/dialog_comment_content"),"好");
//                actionManager.ClickNodes(accesser.findNodesById("com.xiangzi.jukandian:id/dialog_comment_send"));
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void huishiping( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.Click(100,100);
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Back();
            Thread.sleep(3000);
            actionManager.Home_Up(3,200);
            actionManager.ClickText("观看");
            if ( checkactivity()){
                actionManager.ClickText("继续播放");
                wrong=wrongtimes;
                setpage(globalapp);
                Thread.sleep(62000);
                actionManager.ClickId("com.cashvideo:id/iv_video_time_bg");
                Thread.sleep(2000);
                if (checkactivity()){
                    actionManager.Back();
                }else{
                    actionManager.Back();
                    actionManager.Back();
                }
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void taozuiredian( ) throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.ClickText("人看过");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                Thread.sleep(3000);
                actionManager.Home_Up(2,150);
                actionManager.ClickDesc("查看全文");
                actionManager.Click(400,200);
                actionManager.Click(400,230);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void taotoutiao( ) throws InterruptedException {
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.ClickId("com.ly.taotoutiao:id/img_hd_close");
        actionManager.Back();
        actionManager.ClickText("领取");
        actionManager.ClickText("任务");
        Thread.sleep(3000);
        actionManager.ClickText("签到");
        actionManager.ClickText("头条");
        actionManager.Back();
        while(time>1&&wrong>1){
            actionManager.ClickId("com.ly.taotoutiao:id/img_hd_close");
            actionManager.OpenAPP();
            actionManager.Back();
            actionManager.Home_Up(2,200);
            actionManager.ClickText("来自");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                Thread.sleep(3000);
                actionManager.ClickDesc("阅读全部内容");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void xiaoju( ) throws InterruptedException {
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.ClickText("继续赚钱");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Back();
            actionManager.ClickText("继续赚钱");
            actionManager.Home_Up(2,200);
            actionManager.ClickId("com.koramgame.xianshi.kl:id/a4e");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(3,200);
                Thread.sleep(2000);
                actionManager.ClickText("点击展开全文");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void dzkandian() throws InterruptedException {
        actionManager.OpenAPP();
        Thread.sleep(15000);
        actionManager.Back();
        actionManager.Home_Down(2,200);
        actionManager.ClickText("领取");
        Thread.sleep(2000);
        actionManager.ClickText("任务中心");
        Thread.sleep(2000);
        actionManager.ClickText("立即签到");
        Thread.sleep(2000);
        actionManager.ClickText("看点");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Back();
            actionManager.Home_Up(2,200);
            actionManager.ClickText("2019-");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.Home_Up(2,200);
                Thread.sleep(2000);
                actionManager.ClickDesc("展开全文");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void tutoutiao() throws InterruptedException {
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.Back();
        Thread.sleep(1000);
        actionManager.ClickText("继续赚钱");
        actionManager.Home_Down(2,200);
        actionManager.ClickId("com.news.tutoutiao:id/fh_iv_boxgif");
        Thread.sleep(1000);
        actionManager.ClickId("com.news.tutoutiao:id/close_view");
        Thread.sleep(1000);
        actionManager.ClickId("com.news.tutoutiao:id/fl_makemoney");
        Thread.sleep(1000);
        actionManager.ClickId("com.news.tutoutiao:id/close_view");
        Thread.sleep(1000);
        actionManager.ClickText("首页");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.ClickText("阅读");
            Thread.sleep(2000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                if( actionManager.ClickText("可领取")){
                    actionManager.ClickDesc("可领取");
                    Thread.sleep(2000);
                    actionManager.Back();
                }
                actionManager.News_Down(2,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void xintoutiao() throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.Back();
        Thread.sleep(3000);
        actionManager.ClickText("时段奖励");
        actionManager.Back();
        actionManager.ClickText("任务");
        actionManager.Back();
        Thread.sleep(2000);
        actionManager.ClickText("资讯");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(3000);
            actionManager.Back();
            actionManager.Home_Up(2,200);
            actionManager.Click(350,480);
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Down(2,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void kuaima() throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.Back();
        Thread.sleep(3000);
        actionManager.ClickId("com.kuaima.browser:id/view_account");
        actionManager.ClickText("立即签到");
        actionManager.Back();
        Thread.sleep(2000);
        actionManager.ClickId("com.kuaima.browser:id/view_main");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(3000);
            actionManager.Back();
            actionManager.Home_Up(2,200);
            actionManager.ClickId("com.kuaima.browser:id/tv_readnumber");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Up(3,200);
                actionManager.ClickText("展开查看全文");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void jiuhuang() throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.ClickText("领现金");
        Thread.sleep(3000);
        actionManager.ClickText("头条");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.ClickText("头条");
            Thread.sleep(2000);
            actionManager.Home_Up(2,200);
            actionManager.ClickText("阅读");
            Thread.sleep(2000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Up(3,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void aishang() throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(16000);
        actionManager.Back();
//        actionManager.ClickText("任务");
//        Thread.sleep(600);
//        actionManager.ClickId("com.aladdin.asttnews:id/iv_box");
//        Thread.sleep(300);
//        actionManager.ClickId("com.aladdin.asttnews:id/iv_sign_in");
//        Thread.sleep(300);
//        actionManager.Back();
//        Thread.sleep(2000);
//        actionManager.ClickText("首页");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(3000);
            actionManager.Home_Up(2,200);
            actionManager.ClickId("com.aladdin.asttnews:id/news_time");
            Thread.sleep(3000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Up(3,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void baiwan() throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.ClickText("领取");
        actionManager.ClickText("忽略");
        Thread.sleep(1000);
        actionManager.Click(430,1246);
        Thread.sleep(1000);
        actionManager.Click(650,250);
        Thread.sleep(1000);
        actionManager.ClickText("刷新");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(1000);
            actionManager.Home_Up(2,200);
            actionManager.ClickText("阅读");
            Thread.sleep(1500);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Up(2,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void ydxw() throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.Back();
        actionManager.ClickText("我的钱包");
        actionManager.Click(640,170);
        actionManager.ClickId("com.hkzy.ydxw:id/redpacket_open");
        actionManager.ClickText("任务大厅");
        actionManager.Click(360,300);
        actionManager.Back();
        actionManager.ClickText("主页");
        actionManager.ClickId("com.hkzy.ydxw:id/tv_time");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(1000);
            actionManager.Home_Up(2,200);
            actionManager.ClickId("com.hkzy.ydxw:id/tv_time");
            Thread.sleep(1500);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Up(2,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void ttjx() throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.Back();
        actionManager.ClickText("赚钱");
        actionManager.Click(368,430);
        actionManager.ClickText("首页");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            Thread.sleep(1000);
            actionManager.Home_Up(2,200);
            actionManager.ClickText("阅读");
            Thread.sleep(1500);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Up(2,200);
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }
    public void netease() throws InterruptedException{
        actionManager.OpenAPP();
        Thread.sleep(13000);
        actionManager.Back();
        actionManager.ClickText("领取");
        Thread.sleep(1000);
        actionManager.Back();
        actionManager.ClickText("任务");
        Thread.sleep(2000);
        actionManager.Click(360,200);
        Thread.sleep(1000);
        actionManager.Back();
        actionManager.ClickText("首页");
        while(time>1&&wrong>1){
            actionManager.OpenAPP();
            actionManager.Home_Up(2,200);
            actionManager.ClickId("com.netease.news.lite:id/gq");
            Thread.sleep(2000);
            if (checkactivity()){
                wrong=wrongtimes;
                setpage(globalapp);
                actionManager.News_Up(3,200);
                actionManager.ClickDesc("查看全文");
                actionManager.ReadNews();
                time-=1;
            }else {
                wrong-=1;
                actionManager.Back();
            }
            settime(globalapp,false);
        }
        actionManager.Close(globalapp.packname);
    }

    public boolean checkactivity() throws InterruptedException {
        if (!globalapp.newsname.equals("nothing")&&NowClassName.equals(globalapp.newsname)){
            return true;
        }else if (!globalapp.VideoActivity.equals("nothing")&&video_read&&NowClassName.equals(globalapp.VideoActivity)){
            return true;
        }else if (!globalapp.backactivity1.equals("nothing")&&NowClassName.equals(globalapp.backactivity1)){
            return true;
        }else if (!globalapp.backactivity2.equals("nothing")&&NowClassName.equals(globalapp.backactivity2)){
            return true;
        }else if (!globalapp.backactivity3.equals("nothing")&&NowClassName.equals(globalapp.backactivity3)){
            return true;
        }else if (!globalapp.backactivity4.equals("nothing")&&NowClassName.equals(globalapp.backactivity4)){
            return true;
        }else if (!globalapp.FlagText1.equals("nothing")&& actionManager.TextExist(globalapp.FlagText1)){
            return true;
        }else if (!globalapp.FlagText2.equals("nothing")&& actionManager.TextExist(globalapp.FlagText2)){
            return true;
        }else if (!globalapp.FlagId1.equals("nothing")&& actionManager.IdExist(globalapp.FlagId1)){
            return true;
        }else if (!globalapp.FlagId2.equals("nothing")&&actionManager.IdExist(globalapp.FlagId2)){
            return true;
        }
        return false;
    }

    public void init(){
        this.time= globalapp.pagenumber;
        wrong=wrongtimes;
        ToastUtils.getInstance().show(MyApplication.globalapp.zname+"开始运行");
        settime(globalapp,true);
    }
    public void settime(App app,Boolean run){
        if (run){
            begintime =System.currentTimeMillis();
            app.ReadCount =0;
        }else {
            app.UseTime=(System.currentTimeMillis()-begintime);
            ShareUtil.getInstance().AppSet(app);
            begintime =System.currentTimeMillis();
            app.ReadCount =0;
        }
    }
    public void setpage(App app){
        app.ReadCount +=1;
        cycle_time=time;
    }


}